<template>
 <view class="main">
   <view class="logo">
	 <view class="ilist" @click="myitem">
		<view class="ilist1"></view> 
		<view class="ilist2"></view> 
	 </view>
	 <image src="https://ppp.new.zeroitem.cn/ppp/logo.png"  style="width:148rpx;height:64rpx"></image>   
   </view>
   <view class="menu">
	 <view class="menu-1" @click="jumpmenu(1)"><view class="dot"></view>一键下单</view>
	 <view class="menu-1" @click="jumpmenu(2)">约拍同款</view>
	 <view class="menu-1" @click="jumpmenu(3)">定制悬赏</view> 
	 <view class="menu-1 cur">当前订单</view>
   </view>
   <view class="main1">
	   <view class="part1">
		  <view class="pp1-1" @click="settab(1)" :class="[{'pcur' : tab==1}]">
			 <view class="ptxt1">{{tj.cnt2}}</view>
			 <view class="ptxt2">进行中</view>
		  </view>
		  <view class="ppline1"></view>
		  <view class="pp1-2" @click="settab(2)" :class="[{'pcur' : tab==2}]">
			<view class="ptxt1">{{tj.cnt3}}</view>
			<view class="ptxt2">已完成</view>  
			  
		  </view>
		  <view class="ppline1"></view>
		  <view class="pp1-3" @click="settab(0)" :class="[{'pcur' : tab==0}]">
			 <view class="ptxt1">{{tj.cnt1}}</view>
			 <view class="ptxt2">总计</view> 
			  
		  </view>
	   </view>
	   <view class="part2">
		 <view class="item1" v-for="(item,index) in orderlist">
		   <view class="item1-1" @click="gorder(item.id)">
			 <view class="itxt2">【{{item.ptype}}】</view>
			 <view class="itxt1">{{item.total_price}}￥</view>
			<block v-if="item.step==1">
			<view class="itxt8">待接单</view>
			<image src="https://ppp.new.zeroitem.cn/ppp/sm1.png" class="img1"></image>
			</block>
			<block v-if="item.step>1">
			<view class="itxt8">{{item.pname}}</view>
			<image :src="item.pavatar" class="img1"></image>
			</block>
		   </view>
		   <view class="item1-2">
			 <view class="itxt3" @click="gorder(item.id)">
			   <view class="itxt3-1">
				 <image src="https://ppp.new.zeroitem.cn/ppp/tip2.png" class="img3"></image> 
				  <view class="it3-1">
					<view>{{item.pdate}}</view> 
					<view>{{item.ptime}}</view>  
				  </view>
			   </view> 
			   <view class="itxt3-2">
			     <image src="https://ppp.new.zeroitem.cn/ppp/sm2.png" class="img3"></image> 
				  <view class="it3-1">
					{{item.address}}
				  </view>				   
			   </view> 
			 </view>
				<video :src="item.src1" style="width:318rpx;height:162rpx" objectFit="cover" :id="'id'+item.id" @play="videoPlayHandle('id'+item.id)" v-if="item.play==1"></video>
				<image :src="item.video_pic" style="width:318rpx;height:162rpx" v-if="item.play==0" @click="showplay(index)"></image>
		   </view>
		   <view class="item1-3" @click="gorder(item.id)">
			   <view class="itxt4">订单号：{{item.ordersn}}</view>
			  <view class="itxt5" v-if="item.step==-1 && item.qinfo.zt==0">取消中</view>
			  <view class="itxt5" v-if="item.step==-1 && item.qinfo.zt==1">已取消</view>
			   <view class="itxt5" v-if="item.step==1">待接单</view>
			   <view class="itxt5 ibg" v-if="item.step==2">已接单</view>
			   <view class="itxt5 ibg" v-if="item.step==3">已开始</view>
			   <view class="itxt5 ibg" v-if="item.step==4">已提交</view>
			   <view class="itxt5" v-if="item.step==5">待确认</view>
			   <view class="itxt5 ibg" v-if="item.step==6">已完成</view>
		   </view>
		 </view> 
	   </view>	      
   </view>
   
   
   
  </view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		toLogin
	} from '@/utils/login'
	
	import {
		loadingFun,
		menuJump
	} from '@/utils/tools'	
	
    import {
		loadingType
	} from '@/utils/type'
	
    import {
	  getorderlist,pslist,countorder
	} from '@/api/ppp'	
  const app = getApp()		
  export default {
	    data() {
	        return {
			 orderlist:[],
			 total:0,
			 tab:0,
			 tj:[],
			 cnt_complete:0,
			 cnt_process:0,
			 video:null,
			 page: 1,
			 status: loadingType.LOADING
	        }
	    },
		onShow(){

		},
		onLoad(){
		 this.myorder(); 
		 this.total_order();	 
		},
		onReachBottom() {
		 this.myorder();
		 setTimeout(() => {
		 	uni.stopPullDownRefresh();
		 }, 1000);	
		},
	    methods: {
		async total_order(){
			 var that=this;
			 const{
			  code,
			  msg,
			  data
			 }= await countorder({type:1}); 
			 this.tj=data;
		},
		showplay(index){
			  var that=this;
			  var orderlist=that.orderlist;
			  if(orderlist[index].has_video==0){
				uni.showToast({title:'当前没有视频',icon:'none'});
			    return false;	  
			  }
			  orderlist[index].play=1;
			  orderlist[index].src1=orderlist[index].video_src;
			  that.orderlist=orderlist;
			  that.videoPlayHandle('id'+orderlist[index].id); 
			},
		    videoPlayHandle(id) {
			let newVideo = uni.createVideoContext(id);
			newVideo.id = id;
			if (!this.video) {
				this.video = newVideo;
				this.video.play();
				return
			}
			if (this.video.id !== newVideo.id) {
				newVideo.play();
				this.video.pause();
				this.video = newVideo;
			}
		},
		gorder(zt){
		 uni.navigateTo({
		 	url:"/pages/ppp/order/order1?oid="+zt
		 })	
		},	
		myitem(){
		 uni.navigateTo({
		 	url:"/pages/ppp/my/index"
		 })	
		},
		settab(tab){
		 this.tab=tab;	
		 this.page=1;
		 this.orderlist=[];
		 this.status=loadingType.LOADING;
		 this.myorder();
		},
	    async myorder(){
			 //const data = await loadingFun(pslist,this.page,this.plist,this.status,{});
			 const data = await loadingFun(getorderlist,this.page,this.orderlist,this.status,{tab:this.tab});
			if (!data) return
			this.page = data.page
			this.orderlist = data.dataList
			this.status = data.status	  
		},
		jumpmenu(kn){
		if(kn==1){
		  uni.redirectTo({
			 url:"/pages/ppp/index/order"
		  })
		 }	
		 if(kn==2){
		   uni.redirectTo({
		 	 url:"/pages/ppp/index/drps"
		   })
		  }	
		 if(kn==3){
		   uni.redirectTo({
		 	 url:"/pages/ppp/index/dzxx"
		   })
		  }	
		 if(kn==4){
		   uni.redirectTo({
		 	 url:"/pages/ppp/index/dqdd"
		   })
		  }					
		  
		},
	    },
	   computed: {
	  	...mapGetters(['isLogin']),
	   }	
		
	}	
</script>

<style>
@import "./dqdd.css";	
</style>
